package src.twice;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

//public class ReplaceTool {
//
//    protected void do_replaceButton_actionPerformed(ActionEvent e){
//        String before = beforeTextField.getText();
//        //省略校验代码
//        FileReader reader = null;
//        FileWriter writer = null;
//        StringBuilder sb = new StringBuilder();
//        int flag = 0;
//        try{
//            reader = new FileReader(textFile);
//            while ((flag = reader.read(temp)) != -1){
//                sb.append(temp);
//            }
//            String content = sb.toString().replace(before, after);
//            writer = new FileWriter(textFile);
//            writer.write(content);
//        } catch (IOException ex) {
//            throw new RuntimeException(ex);
//        }finally {
//            try {
//                writer.close();
//                reader.close();
//            } catch (IOException ex) {
//                throw new RuntimeException(ex);
//            }
//        }
//        JOptionPane.showMessageDialog(this,"字符串替换成功！");
//        return;
//
//    }

//}
